package com.fhz.day006;

import androidx.room.AutoMigration;
import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;

/**
 * 时间:2022/5/24
 *
 * @author msfeng
 * 简述: 创建数据库操作对象
 */
@Database(entities = {User.class},version = 3,autoMigrations = @AutoMigration(from = 2,to = 3))
public abstract class AppDatabase extends RoomDatabase {

    public abstract UserDao userDao();

    private static AppDatabase appDatabase;

    public static AppDatabase getInstance(){
        if(appDatabase == null){
            appDatabase = Room.databaseBuilder(App.context,
                    AppDatabase.class, "user-info")
                    .allowMainThreadQueries()
//                    .addMigrations()
                    .build();
        }
        return appDatabase;
    }



}

